// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name:   Tyg_txQuery1.java


//Changing this program to allow update

package MaintMenu.VenPricingUpdMasterFiles;

import javax.swing.*;
import java.sql.*;

public class TemplateforLItoBKdataExchange
{

    public TemplateforLItoBKdataExchange(String poid)
    {
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection con = DriverManager.getConnection(dbURL, "", "");
            Statement st = con.createStatement();
            Statement st2 = con.createStatement();
            Statement st3 = con.createStatement();
            Statement st4 = con.createStatement();
            Statement st5 = con.createStatement();
            String dataSourceName6 = "dbBL";
            String dbURL6 = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName6).toString();
            Connection con6 = DriverManager.getConnection(dbURL6, "", "");
            Statement st6 = con6.createStatement();
            Statement st7 = con6.createStatement();
            Statement st8 = con6.createStatement();

            long containerKey = 0L;


            String duedate = null;
            String duedate1 = null;
            long invid = 0L;
            String part_no = null;
            double quantity = 0.0D;
            double unitprice = 0.0D;
            String description = null;
            String description1 = null;

            try
            {
//                        st6.execute("delete * from tblbc_work;");
//                        st6.execute("delete * from tblbc_temp;");
//                        //create an entry in tblcontainerheader in Brooklyn
//                        st6.execute("insert into tblcontainerheader(containerkey,container,arrival) values (" + containerKey + ", '" + container + "',#" + duedate1 + "#);");
                //get purchaseorderdetail by poid(i.e. MR130503BKgn) from Hicksville Data
                st3.execute("select [part#] as part_no, duedate, invid, quantity, unitprice, description from tblpurchaseorderdetail where poid = " + poid + ";");
                for(ResultSet rs3 = st3.getResultSet(); rs3.next();)
                {
                    //data read from dbli
                    invid = rs3.getLong("invid");
                    part_no = rs3.getString("part_no");
                    quantity = rs3.getDouble("quantity");
                    unitprice = rs3.getDouble("unitprice");
                    description = rs3.getString("description");
                    description1 = description.replace('\'', ' ');
                    try
                    {
                        //push data from above to dbbl
                        st7.execute("INSERT INTO TBLCONTAINERDETAIL ( CONTAINERKEY, INVID, PN, QTY, RECEIVED ) values(" + containerKey + ", " + invid + ", '" + part_no + "', " + quantity + ", 0);");
                        st8.execute("INSERT INTO TBLBC_WORK ( [PART#], SUPPLIER, TYG_TX, TYG_TX_P, TYG_TX_QP, [TYG_TX#], description ) values('" + part_no + "', 'X', " + quantity + ", " + unitprice + ", " + unitprice + ", null, '" + description1 + "');");
                    }
                    catch(SQLException er) {
                        JOptionPane.showMessageDialog(null, er);

                    }
                }

//                        st6.execute("INSERT INTO TBLBC_TEMP SELECT * FROM TBLBC_WORK;");
            }
            catch(SQLException er)
            {
                er.printStackTrace();
                JOptionPane.showMessageDialog(null, er);
            }
            st.close();
            st2.close();
            st3.close();
            st4.close();
            st5.close();
            st6.close();
            st7.close();
            st8.close();
            con.close();
            con6.close();
        }
        catch(Exception e)
        {
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, e);
        }
    }
}
